package com.consume.controller;
import com.consume.clients.Userclient;
import com.consume.config.PatternProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @ClassName: ConsumeController
 * @Description:
 * @date: 2021/11/18 15:49
 */
@Slf4j
@Controller
@RequestMapping("/consume")
@RefreshScope  //热部署bootstrap.yaml文件配置,配合@value注解使用
public class ConsumeController {

    @Value("${userprofile.datasource.url}")
    private  String name;

    @Autowired
    private Userclient userclient;

    @RequestMapping(value ="/getname",method = RequestMethod.GET)
    public @ResponseBody
    String hello(){
        log.info("进来了:{}",name);
//        String result=userclient.getid(id);
        System.out.println(name);
        return name;
    }
//    private String url="http://user-service/service/";

//    @Autowired
//    private RestTemplate restTemplate;

//    @Autowired
//    private PatternProperties patternProperties;
//    @Value("${pattern.dateformat}")
//    private String dateformat;
//
//    @GetMapping("/gettime")
//    public @ResponseBody String gettime(){
//        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(patternProperties.getDateformat()));
//    }

//    @RequestMapping(value ="/{id}",method = RequestMethod.GET)
//    public @ResponseBody
//    String hello(@PathVariable("id") String id){
//        log.info("进来了"+id);
//        String result=restTemplate.getForObject(url+id,String.class);
//        System.out.println(result);
//        return result;
//    }
}
